﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.Text;
using System.Threading.Tasks;

namespace Simhopp.Common
{
    public enum Genders { Male, Female, DEFAULT };

    [Serializable]
    public class Credentials : ISerializable
    {
        #region FIELD REGION
        private String name;
        private Genders gender;
        private int age;
        private String nationality;
        #endregion
        #region CONSTRUCTOR REGION
        public Credentials(String name = "", 
            Genders gender = Genders.DEFAULT,
            int age = 0,
            String nationality = "")
        {
            this.name = name;
            this.gender = gender;
            this.age = age;
            this.nationality = nationality;
        }
        #endregion
        #region PROPERTY REGION
        public String Name
        {
            get { return name; }
            set { name = value; }
        }
        public Genders Gender
        {
            get { return gender; }
            set { gender = value; }
        }
        public int Age 
        {
            get { return age; }
            set { age = value; }
        }
        public String Nationality 
        {
            get { return nationality; }
            set { nationality = value; }
        }
        #endregion
        #region SERIALIZE/DESERIALIZE REGION
        public void GetObjectData(SerializationInfo info, StreamingContext context)
        {
            info.AddValue("Name", name, typeof(String));
            info.AddValue("Gender", gender, typeof(Genders));
            info.AddValue("Age", age, typeof(int));
            info.AddValue("Nationality", nationality, typeof(String));
        }
        protected Credentials(SerializationInfo info, StreamingContext context)
        {
            name = (String)info.GetValue("Name", typeof(String));
            gender = (Genders)info.GetValue("Gender", typeof(Genders));
            age = (int)info.GetValue("Age", typeof(int));
            nationality = (String)info.GetValue("Nationality", typeof(String));
        }
        #endregion
    }
}
